

class Toast {
    // 提示
    info({message='',duraction=2000}){
      this.clear()
      const containerTarget = document.createElement('div');
      containerTarget.className = 'y_taost_container'
      const innerTarget = document.createElement('div');
      innerTarget.className = 'y_taost_container-inner'
      innerTarget.innerText = message;
      containerTarget.appendChild(innerTarget)
      document.body.appendChild(containerTarget);
      setTimeout(() => {
          containerTarget.remove()
      }, duraction);
    }
    // 清除
    clear(){
        const toastTarget = document.querySelector('.y_taost_container')
        if(toastTarget){
            toastTarget.remove()
        }
    }
}

export default new Toast()